﻿using HelperFromTheSkeleton.Enums;
using HelperFromTheSkeleton.Model.PageModel;
using System.Linq.Expressions;

namespace HelperFromTheSkeleton.EFBaseRepository
{
    public interface IEFBaseRepository<T>
    {
        /// <summary>
        /// 获取单个
        /// </summary>
        /// <param name="expression">查询条件</param>
        /// <returns></returns>
        T? First(Expression<Func<T, bool>>? expression = null);

        /// <summary>
        /// 获取单个
        /// </summary>
        /// <param name="expression">查询条件</param>
        /// <returns></returns>
        Task<T?> FirstAsync(Expression<Func<T, bool>>? expression = null);

        /// <summary>
        /// 列表查询
        /// </summary>
        /// <param name="expression">查询条件</param>
        /// <param name="orderByExpression">排序方式</param>
        /// <param name="orderByEnum">排序方式</param>
        /// <returns></returns>
        List<T> Find(Expression<Func<T, bool>>? expression = null, Expression<Func<T, object>>? orderByExpression = null, OrderByEnum? orderByEnum = null);

        /// <summary>
        /// 查询数量
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        Task<int> CountAsync(Expression<Func<T, bool>>? expression = null);

        /// <summary>
        /// 查询数量
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        int Count(Expression<Func<T, bool>>? expression = null);

        /// <summary>
        /// 列表查询
        /// </summary>
        /// <param name="expression">查询条件</param>
        /// <param name="OrderParameter">多条件排序参数</param>
        /// <returns></returns>
        List<T> Find(Expression<Func<T, bool>>? expression = null, List<(Expression<Func<T, object>>, OrderByEnum)>? OrderParameter = null);

        /// <summary>
        /// 列表查询
        /// </summary>
        /// <param name="expression">查询条件</param>
        /// <param name="orderByExpression">排序条件</param>
        /// <param name="orderByEnum">排序方式</param>
        /// <returns></returns>
        Task<List<T>> FindAsync(Expression<Func<T, bool>>? expression = null, Expression<Func<T, object>>? orderByExpression = null, OrderByEnum? orderByEnum = null);

        /// <summary>
        /// 列表查询
        /// </summary>
        /// <param name="expression">查询条件</param>
        /// <param name="orderByExpression">排序条件</param>
        /// <param name="orderByEnum">排序方式</param>
        /// <returns></returns>
        Task<List<T>> FindAsync(Expression<Func<T, bool>>? expression = null, List<(Expression<Func<T, object>>, OrderByEnum)>? OrderParameter = null);

        /// <summary>
        /// 列表分页查询
        /// </summary>
        /// <param name="page">分页条件</param>
        /// <param name="expression">查询条件</param>
        /// <param name="orderByExpression">排序条件</param>
        /// <param name="orderByEnum">排序方式</param>
        /// <returns></returns>
        Task<(List<T>, PageResultModel)> PageFindAsync(PageModel page, Expression<Func<T, bool>>? expression = null, Expression<Func<T, object>>? orderByExpression = null, OrderByEnum? orderByEnum = null);

        /// <summary>
        /// 列表分页查询
        /// </summary>
        /// <param name="page">分页条件</param>
        /// <param name="expression">查询条件</param>
        /// <param name="orderByExpression">排序条件</param>
        /// <param name="orderByEnum">排序方式</param>
        /// <returns></returns>
        Task<(List<T>, PageResultModel)> PageFindAsync(PageModel page, Expression<Func<T, bool>>? expression = null, List<(Expression<Func<T, object>>, OrderByEnum)>? OrderParameter = null);
    }
}
